;; -*- coding: utf-8 -*-
;; A short dotemacs file
;; Written by Qichen Huang (jasonal00@gmail.com)
;; Time-stamp: <2007-06-10 14:45:09>

(add-to-list 'load-path "~/.emacs.d")

;; add the subdirectories to load path
(defun my-add-subdirs-to-load-path (dir)
 (let ((default-directory (concat dir "/")))
  (setq load-path (cons dir load-path))
  (normal-top-level-add-subdirs-to-load-path)))

(my-add-subdirs-to-load-path "~/.emacs.d")

;; some configurations
;; close startup message
(setq inhibit-startup-message t)

;; display column number
(setq column-number-mode t)

;; set maximum kill-ring to 200
(setq kill-ring-max 200)

;; highlight keywords
(setq global-font-lock-mode t)

;; recursive commands in minibuffer
(setq enable-recursive-minibuffers t)

;; make cursor movement more comfortable
(setq scroll-margin 3)
(setq scroll-conservatively 10000)

;; highlight marked region
(setq transient-mark-mode t)

;; display images
(setq auto-image-file-mode t)

;; highlight parenthese
(show-paren-mode t)

;; parenthese style
(setq show-paren-style 'parentheses)

;; icomplete mode in minibuffer
(icomplete-mode t)

;; so you can type e.g. p-c-m <tab> to complete partial-completion-mode
(partial-completion-mode t)

;; hide menu-bar
(menu-bar-mode -1)

;; hide tool-bar
(tool-bar-mode -1)

;; hide scroll-bar
(scroll-bar-mode -1)

;; use visible bell instead of the noisy warning bell
(setq visible-bell t)

;; share the x window clipboard (windows user don't need this)
(setq x-select-enable-clipboard t)

;; mouse will jump away if the cursor is near it
(mouse-avoidance-mode 'animate)

;; use 24-hour display mode. I'm getting confused about AM and PM
(setq display-time-24hr-format t)

;; display time and date on the mode-line
(setq display-time-day-and-date t)
(display-time)

;; split the window horizontally when use ediff      
(setq ediff-split-window-function 'split-window-horizontally)

;; don't blink the cursor
(blink-cursor-mode -1)

;; set some keybindings since C-@ may be not available on a german keyboard
;; Now you can also use C-" or C-x <SPC> to set mark
(global-set-key (kbd "C-\"") 'set-mark-command)
(global-set-key (kbd "C-x <SPC>") 'set-mark-command)

;; enable some useful functions
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'scroll-left 'disabled nil)

;; C-x n n
;; C-x n d
;; C-x n p
;; C-x n w widen
(put 'narrow-to-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)

;; use y or n instead of yes or no answer
(fset 'yes-or-no-p 'y-or-n-p)

;; you might need this if you are on a Windows system
;; and have files with chinese names
(if (eq window-system 'w32)
    (progn
      (set-language-environment 'chinese-gb)
      ;;(set-file-name-coding-system 'chinese-gb)
      ))

(require 'ido nil t)
(when (featurep 'ido)
  (ido-mode t)
  (setq ido-slow-ftp-host-regexps '(".*"))
  (setq ido-save-directory-list-file "~/.emacs.d/.ido.last"))

(require 'ibuffer nil t)
(when (featurep 'ibuffer)
  (global-set-key (kbd "C-x C-b") 'ibuffer)
  (autoload 'ibuffer "ibuffer" "List buffers." t))

;; font-set for windows
(if (eq window-system 'w32)
    (progn 
      (create-fontset-from-fontset-spec
       "-outline-Courier New-normal-r-*-*-13-97-96-96-c-*-fontset-courier")
      (set-fontset-font			
       "fontset-courier" nil
       "-outline-新宋体-*-r-*-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
      (set-fontset-font
       "fontset-courier" 'kana
       "-outline-新宋体-*-r-*-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
      (set-fontset-font
       "fontset-courier" 'han
       "-outline-新宋体-*-r-*-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
      (set-fontset-font
       "fontset-courier" 'cjk-misc
       "-outline-新宋体-*-r-*-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
      (set-fontset-font
       "fontset-courier" 'symbol
       "-outline-新宋体-*-r-*-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
      (set-default-font "fontset-courier")
      ))
